package com.sakura.mybatis.version3.doctor.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.util.ListUtils;
import com.sakura.mybatis.version3.doctor.excel.FinalExcel;
import com.sakura.mybatis.version3.doctor.excel.ResultExcel;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * @Author Sakura
 * @Date 2023/7/2 20:37
 * @Version 1.0
 */
@Slf4j
public class ResultExcelListener extends AnalysisEventListener<ResultExcel> {


    /**
     * 缓存的数据
     */
    private List<ResultExcel> cachedDataList = null;

    public ResultExcelListener(List<ResultExcel> cachedDataList) {
        this.cachedDataList = cachedDataList;
    }

    @Override
    public void invoke(ResultExcel resultExcel, AnalysisContext analysisContext) {
        this.cachedDataList.add(resultExcel);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {
        log.info("经络体征所有数据解析完成！共{}条数据", cachedDataList.size());
    }
}
